package com.lz.EnvironmentTest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 测试spring的环境变量功能引擎
 */
@SpringBootApplication
public class EnvironmentApp {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(EnvironmentApp.class, args);
        String environment = context.getEnvironment().getProperty("spring.profiles.active");
        System.out.println("当前环境变量：" + environment);
        context.getEnvironment().getSystemEnvironment().forEach((k, v) -> System.out.println(k + "=" + v));
        System.out.println("-------------------------------------------------");
        context.getEnvironment().getSystemProperties().forEach((k, v) -> System.out.println(k + "=" + v));

    }
}
